<?php

require_once dirname(__FILE__).'/../lib/TestGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/TestGeneratorHelper.class.php';

/**
 * Test actions.
 *
 * @package    tests
 * @subpackage Test
 * @author     Djul
 * @version    SVN: $Id: actions.class.php 12474 2008-10-31 10:41:27Z fabien $
 */
class TestActions extends autoTestActions
{
    public function executeListQuestions(sfWebRequest $request)
    {
        $this->getUser()->setAttribute('question.filters', array('test_id' => $request->getParameter('id')), 'admin_module');
        $this->redirect('@question');
    }

  public function executeChangePublishedStatus(sfWebRequest $request)
  {
    $test = TestPeer::retrieveByPk($this->getRequestParameter('id'));
    $currentStatus = $test->getIsPublished();
    $newStatus = ($currentStatus == 1 ? 0 : 1);

    $test->setIsPublished($newStatus);
    $test->save();
    
    $this->test = $test;
  }
}
